Use the caret-color properties for drawing carets
authorMatthias Clasen <mclasen@redhat.com>
Thu, 7 Jan 2016 03:07:09 +0000 (22:07 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 8 Jan 2016 12:33:20 +0000 (07:33 -0500)
Replace the cursor-color and secondary-cursor-color style
properties with the caret-color and -gtk-secondary-caret-color
CSS properties.

For the 'auto' value of these properties, we keep the same
behavior that we used to have when the style properties are
not explicitly set.

gtk/gtkstylecontext.c

index d108e0f4775e14b3cb46790e1d7659c6fac795b3..a6a6a3bc81b4c3501c6242508db16f2b0d654171 100644 (file)
@@ -35,6 +35,7 @@
 #include "gtkcssnumbervalueprivate.h"
 #include "gtkcsspathnodeprivate.h"
 #include "gtkcssrgbavalueprivate.h"
+#include "gtkcsscolorvalueprivate.h"
 #include "gtkcssshadowsvalueprivate.h"
 #include "gtkcssstaticstyleprivate.h"
 #include "gtkcssstylepropertyprivate.h"
@@ -2755,62 +2756,26 @@ gtk_style_context_get_font (GtkStyleContext *context,
   return description;
 }
 
-static void
-get_cursor_color (GtkStyleContext *context,
-                  gboolean         primary,
-                  GdkRGBA         *color)
-{
-  GdkColor *style_color;
-
-  gtk_style_context_get_style (context,
-                               primary ? "cursor-color" : "secondary-cursor-color",
-                               &style_color,
-                               NULL);
-
-  if (style_color)
-    {
-      color->red = style_color->red / 65535.0;
-      color->green = style_color->green / 65535.0;
-      color->blue = style_color->blue / 65535.0;
-      color->alpha = 1;
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-      gdk_color_free (style_color);
-G_GNUC_END_IGNORE_DEPRECATIONS
-    }
-  else
-    {
-      GtkStateFlags state;
-
-      state = gtk_style_context_get_state (context);
-
-      gtk_style_context_get_color (context, state, color);
-
-      if (!primary)
-      {
-        GdkRGBA bg;
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-        gtk_style_context_get_background_color (context, state, &bg);
-G_GNUC_END_IGNORE_DEPRECATIONS
-
-        color->red = (color->red + bg.red) * 0.5;
-        color->green = (color->green + bg.green) * 0.5;
-        color->blue = (color->blue + bg.blue) * 0.5;
-      }
-    }
-}
-
 void
 _gtk_style_context_get_cursor_color (GtkStyleContext *context,
                                      GdkRGBA         *primary_color,
                                      GdkRGBA         *secondary_color)
 {
+  GdkRGBA *pc, *sc;
+
+  gtk_style_context_get (context,
+                         gtk_style_context_get_state (context),
+                         "caret-color", &pc,
+                         "-gtk-secondary-caret-color", &sc,
+                         NULL);
   if (primary_color)
-    get_cursor_color (context, TRUE, primary_color);
+    *primary_color = *pc;
 
   if (secondary_color)
-    get_cursor_color (context, FALSE, secondary_color);
+    *secondary_color = *sc;
+
+  gdk_rgba_free (pc);
+  gdk_rgba_free (sc);
 }
 
 static void